﻿using Abp.Configuration.Startup;
using Abp.Localization;
using Abp.Localization.Dictionaries;
using Abp.Localization.Dictionaries.Json;
using Abp.Reflection.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Ny.Ci.Core.Localization
{

    public static class CiLocalizationConfigurer
    {
        public static void Configure(ILocalizationConfiguration localizationConfiguration)
        {
            if (localizationConfiguration.Languages?.FirstOrDefault(p => p.Name == "zh-CN") == null)
            {
                localizationConfiguration.Languages.Add(new LanguageInfo("zh-CN", "简体中文", "famfamfam-flags cn", true));
                localizationConfiguration.Languages.Add(new LanguageInfo("en", "English", "famfamfam-flags england"));
            }


            localizationConfiguration.Sources.Add(
                new DictionaryBasedLocalizationSource(CiConsts.LocalizationSourceName,
                    new JsonEmbeddedFileLocalizationDictionaryProvider(
                        typeof(CiLocalizationConfigurer).GetAssembly(),
                        "Ny.Ci.Core.Localization.SourceFiles"
                    )
                )
            );
        }
    }
}
